package UILayer;
import java.util.*;
import CtrlLayer.*;

public class StatisticsUI
{
    StatisticsController statisticsController;
    public StatisticsUI()
    {
        statisticsController = new StatisticsController();
    }

    public void statisticsMenuStart()
    {

        boolean exit=false;
        while (!exit) 
        {
            int choice = writeStatisticsMenu();

            switch(choice){
                case 1:
                startEmployeeStatistics();
                break;
                case 2:
                startEmployeesStatistics();
                break;
                case 3:
                startProductStatistics();
                break;
                case 4:
                startBestSellerStatistics();
                break;
                case 5:
                startBestLeaserStatistics();
                break;
                case 6:
                startCustomerStatistics();
                break;
                case 7:
                startMostSpendingCustomerStatistics();
                break;
                case 0:
                exit = true;
                break;

            }

        }
    }

    private int writeStatisticsMenu()
    {       

        Scanner keyboard = new Scanner(System.in);
        System.out.println("\f *** Statistics Menu ***");
        System.out.println(" (1) Employee statistics");
        System.out.println(" (2) All employees statistics");
        System.out.println(" (3) Product statistics");
        System.out.println(" (4) Most sold product");
        System.out.println(" (5) Most leased product");
        System.out.println(" (6) Customer statistics");
        System.out.println(" (7) Most spending customer");
        System.out.println(" (0) Back");

        System.out.print("\n Make your choice: ");
        int choice = keyboard.nextInt();
        return choice;
    }
    
    private void startEmployeeStatistics()
    {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Enter the ID of the employee: ");
        int id = Integer.parseInt(keyboard.nextLine());
        statisticsController.employeeStatistics(id);
        pause();
    }
    
    private void startEmployeesStatistics()
    {
        System.out.println("Statistics of all employees:");
        statisticsController.employeesStatistics();
        pause();
    }
    
    private void startProductStatistics()
    {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Enter the barcode of the product: ");
        int barcode = Integer.parseInt(keyboard.nextLine());
        statisticsController.productStatistics(barcode);
        pause();
    }
    
    private void startBestSellerStatistics()
    {
        System.out.println("Most sold statistics: ");
        statisticsController.bestSellerStatistics();
        pause();
    }
    
    private void startBestLeaserStatistics()
    {
        System.out.println("Most leased product: ");
        statisticsController.bestLeaserStatistics();
        pause();
    }
    
    private void startCustomerStatistics()
    {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Enter the ID of the customer: ");
        int id = Integer.parseInt(keyboard.nextLine());
        statisticsController.customerStatistics(id);
        pause();
    }
    
    private void startMostSpendingCustomerStatistics()
    {
        System.out.println("Most spending customer: ");
        statisticsController.mostSpendingCustomerStatistics();
        pause();
    }
    
    private void pause()
    {
        Scanner keyboard = new Scanner(System.in);
        String vent = keyboard.nextLine();
    }

}
